package jp.reflexworks.soap;

import java.util.HashMap;
import java.util.Map;

import jp.reflexworks.soap.model.Login;
import jp.reflexworks.soap.model.RequestHdr;
import jp.reflexworks.soap.protocol.Body;
import jp.reflexworks.soap.protocol.Envelope;
import jp.sourceforge.reflex.IResourceMapper;
import jp.sourceforge.reflex.core.ResourceMapper;

public class ReflexSoapTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Map param = new HashMap();
		param.put("jp.reflexworks.soap.protocol","http://schemas.xmlsoap.org/soap/envelope/");
		param.put( "jp.reflexworks.soap.model","ns1"); 

		IResourceMapper mapper = new ResourceMapper(param);		

		Envelope envelope = new Envelope();
		envelope.body = new Body();
		envelope.body.login = new Login();
		((Login) envelope.body.login).requestHdr = new RequestHdr();

		((Login) envelope.body.login).requestHdr.clientID = "clientid";
		((Login) envelope.body.login).requestHdr.ver = "version";
		((Login) envelope.body.login).requestHdr.ver_$title = "xmlns1";

		String toXML = mapper.toXML(envelope);
		System.out.println("\nSerialized Soap message:");
		System.out.println(toXML);

		Envelope envelope2 = (Envelope) mapper.fromXML(toXML);

		toXML = mapper.toXML(envelope2);
		System.out.println("\nDesirialized SOAP message:");
		System.out.println(toXML);

	}

}
